<template>
  <div class="app-container">
    <div class="table-operation">
      <AuthButton @click="c" name="新增" />
      <el-pagination
        v-bind="elPaginationProps"
        :total="list.total"
        :currentPage.sync="list.filter.pageNo"
        :pageSize.sync="list.filter.pageSize"
      />
    </div>

    <el-table v-loading="list.loading" :data="list.data" v-bind="tableProp">
      <el-table-column label="展示顺序" prop="sort" />
      <el-table-column label="所属地区" prop="areaName" />
      <el-table-column label="顶部图集">
        <template slot-scope="scope">
          <PicViewer :value="scope.row.imgUrl" tableCell />
        </template>
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="{ row }">
          <auth-button @click="u({ id: row.id })" name="编辑" />
          <auth-button @click="d({ id: row.id })" name="删除" />
        </template>
      </el-table-column>
    </el-table>

    <KiFormDialog
      :show.sync="form.show"
      :title="formTitle"
      v-model="form.data"
      :submit="submitForm"
      :readonly="form.status === 'r'"
      ref="formRef"
      :loading="form.loading"
    >
      <template #el-form>
        <el-form-item label="所属地区" prop="areaCode" verify>
          <RegionSelect
            v-model="form.data.areaCode"
            :label.sync="form.data.areaName"
          />
        </el-form-item>
        <el-form-item label="展示顺序" prop="sort" verify>
          <Sort v-model="form.data.sort" />
        </el-form-item>
        <el-form-item label="地区美食图集" prop="imgUrl" verify>
          <Imgpond
            v-model="form.data.imgUrl"
            aspectRatio="355/176"
            :count="9"
          />
        </el-form-item>
        <el-form-item label="简介" prop="briefing" verify>
          <el-input
            v-model="form.data.briefing"
            type="textarea"
            rows="3"
            maxlength="200"
            placeholder="请输入简介"
            show-word-limit
          />
        </el-form-item>
        <el-form-item label="地区美食介绍" prop="richText" verify>
          <MiniMCE v-model="form.data.richText" :disabled="form.status === 'r'"/>
        </el-form-item>
        <el-form-item label="标签" prop="labels">
          <dynamic-tag v-model="form.data.labels" maxlength="10" count="7" />
        </el-form-item>
      </template>
    </KiFormDialog>
  </div>
</template>

<script>
import pageMixin from '@/utils/pageMixin'
import useAdmateAdapter from '@/utils/useAdmateAdapter'
import { DynamicTag } from 'dynamic-tag'

export default {
  mixins: [pageMixin],
  components: { DynamicTag },
  setup: () =>
    useAdmateAdapter({
      urlPrefix: 'one-travel-api/delicious-food-area-profile',
      list: {
        filter: {
          placeId: ''
        }
      }
    })
}
</script>
